package com.rhm.dataStructure.Leetcode;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 23:17
 * @Description:
 **/

import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2020/2/17 23:17
 *@Description:
 **/
/*
整数反转
 */
public class Code7 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        byte a =sc.nextByte();
        System.out.println(reverse(a));
    }
    public static byte reverse(byte x){
        byte rev =0;
        while(x!=0){
            byte pop = (byte) (x%10);
            x= (byte) (x/10);
            if (rev > Byte.MAX_VALUE/10 || (rev == Byte.MAX_VALUE / 10 && pop > 7)) return 0;
            if (rev < Byte.MIN_VALUE/10 || (rev == Byte.MIN_VALUE / 10 && pop < -8)) return 0;
            rev = (byte) (rev*10+pop);
        }
        return rev;
    }
}
